package com.matriq.cloudmanager;

import com.matriq.cloudmanager.R;
import com.matriq.cloudmanager.entity.ClassContacts;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import net.lgpage.activity.BaseActivity;
import net.lgpage.util.Checker.StringUtils;
import net.lgpage.util.IntentUtil;

public class ContactDetailActivity extends BaseActivity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ac_contact_detail);
		setViews();
		setEvents();
		loadData();
	}

	TextView tv_sex;
	TextView tv[] = new TextView[4];
	TextView tv_job;
	LinearLayout viewActionBar;
	TextView tv_name;
	ImageView iv_head;
	TextView tv_title;
	TextView tv_tile;
	ImageButton ll_back;
	LinearLayout ll[] = new LinearLayout[4];
	private void setViews() {
		tv_sex = (TextView) this.findViewById(R.id.tv_sex);
		tv[0] = (TextView) this.findViewById(R.id.tv0);
		tv[1] = (TextView) this.findViewById(R.id.tv1);
		tv[2] = (TextView) this.findViewById(R.id.tv2);
		tv[3] = (TextView) this.findViewById(R.id.tv3);
		ll[0] = (LinearLayout) this.findViewById(R.id.ll0);
		ll[1] = (LinearLayout) this.findViewById(R.id.ll1);
		ll[2] = (LinearLayout) this.findViewById(R.id.ll2);
		ll[3] = (LinearLayout) this.findViewById(R.id.ll3);
		tv_job = (TextView) this.findViewById(R.id.tv_job);
		viewActionBar = (LinearLayout) this.findViewById(R.id.viewActionBar);
		tv_name = (TextView) this.findViewById(R.id.tv_name);
		iv_head = (ImageView) this.findViewById(R.id.iv_head);
		tv_title = (TextView) this.findViewById(R.id.tv_title);
		tv_tile = (TextView) this.findViewById(R.id.tv_tile);
		ll_back = (ImageButton) this.findViewById(R.id.ll_back);
	}

	private void setEvents() {
		ll[0].setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				if(obj!=null&&!StringUtils.isEmpty(obj.getPhone())){
					startActivity(IntentUtil.toCall(obj.getPhone())
							);
				}
			}
		});
	}

	ClassContacts obj;

	public void setData(ClassContacts obj) {
		this.obj = obj;
		if(obj == null)return;
		tv_sex.setText(obj.getSex());
		tv[0].setText(obj.getPhone());
		tv[0].setTextColor(0xff4582fe);
		tv[1].setText(obj.getQQ());
		tv[2].setText(obj.getRoomNum());
		tv[3].setText(obj.getTeam());
		tv_job.setText(obj.getJob());
		tv_name.setText(obj.getName());
		tv_tile.setText(obj.getCommittee());
	}

	private void loadData() {
		obj = (ClassContacts) intentGetObj(ClassContacts.class);
		setData(obj);
	}

	@Override
	public void onDestroy() {
		
		super.onDestroy();
	}

}